//
//  PostSUSViewController.m
//  CarTown
//
//  Created by xionghao on 15/9/9.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "PostSUSViewController.h"
#import "RootTabViewController.h"
#import "CZTabBar.h"
#import "IndexNavViewController.h"
#import "MyCarViewController.h"
#import "CarDetailViewController.h"
#import "LookForDetailController.h"
#import "MyFindBuyViewController.h"
#import "MyAllZCViewController.h"
#import "MyZTTableViewController.h"
#import "addTableViewController.h"
#import "MyZTCarDetailTableViewController.h"
@interface PostSUSViewController ()
@property (weak, nonatomic) IBOutlet UIButton *mybutton;
@property (weak, nonatomic) IBOutlet UIButton *backtobtn;
@property (weak, nonatomic) IBOutlet UILabel *text;
@property (weak, nonatomic) IBOutlet UIButton *contiuebtn;

@end

@implementation PostSUSViewController
+(instancetype)viewcontroller{
    PostSUSViewController *vc=[[PostSUSViewController alloc]initWithNibName:NSStringFromClass([self class]) bundle:nil];
    return vc;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIView *view=[[UIView alloc]init];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:view];
    self.navigationItem.title=@"完成";
    switch (self.type) {
        case POSTCARTYPE:
        { [self.mybutton setTitle:@"我的车源" forState:UIControlStateNormal];
            
            
            self.text.text=@"发布成功";
        }
            break;
        case POSTFINDCARTYPE:
        { [self.mybutton setTitle:@"我的求购" forState:UIControlStateNormal];
            
            self.text.text=@"发布成功";
        }
            break;
        case POSTFINDCARTYPEFROMEIDT:
        { [self.mybutton setTitle:@"我的求购" forState:UIControlStateNormal];
            
            self.text.text=@"修改成功";
        }
            break;
        case POSTZBCARTYPE:
        { [self.mybutton setTitle:@"我的招标" forState:UIControlStateNormal];
            
            self.text.text=@"发布成功";
        }
            break;
        case POSTADDZTCARFROMCARDETAIL:
        { [self.mybutton setTitle:@"展车列表" forState:UIControlStateNormal];
            [self.backtobtn setTitle:@"前往展厅" forState:UIControlStateNormal];
            self.text.text=@"添加成功";
        }
            break;
        case POSTADDZTCARFROMZT:
        { [self.mybutton setTitle:@"展车列表" forState:UIControlStateNormal];
            [self.backtobtn setTitle:@"返回展厅" forState:UIControlStateNormal];
            self.text.text=@"添加成功";
            [self.contiuebtn setTitle:@"继续添加" forState:UIControlStateNormal];
        }
            break;
        case POSTADDZTCARFROMZTEidt:
        { [self.mybutton setTitle:@"展车列表" forState:UIControlStateNormal];
            [self.backtobtn setTitle:@"返回展厅" forState:UIControlStateNormal];
            self.text.text=@"修改成功";
            [self.contiuebtn setTitle:@"继续添加" forState:UIControlStateNormal];
        }
            break;
        default:
            break;
    }
}

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)mycarclick:(id)sender {
    
    switch (self.type) {
        case POSTCARTYPE:
        {
            for (UIViewController *vc in self.childViewControllers) {
                if ([vc isKindOfClass:[MyCarViewController class]]) {
                    [self.navigationController popToViewController:vc animated:YES];
                    return;
                }
            }
            
            MyCarViewController *cavc=[[MyCarViewController alloc]init];
            cavc.hidesBottomBarWhenPushed=YES;
            cavc.isFromSUS=YES;
            [self.navigationController pushViewController:cavc animated:YES];
            
        }
            break;
        case POSTFINDCARTYPE:
        case POSTFINDCARTYPEFROMEIDT:
        {
            for (UIViewController *vc in self.childViewControllers) {
                if ([vc isKindOfClass:[MyFindBuyViewController class]]) {
                    [self.navigationController popToViewController:vc animated:YES];
                    return;
                }
            }
            
            MyFindBuyViewController *cavc=[MyFindBuyViewController Viewcontroller];
            cavc.hidesBottomBarWhenPushed=YES;
            cavc.isFromSUS=YES;
            [self.navigationController pushViewController:cavc animated:YES];
            
        }
            break;
        case POSTADDZTCARFROMZT:
        {
            MyAllZCViewController *vc=[MyAllZCViewController Viewcontroller];
            vc.isFromSUS=YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case POSTADDZTCARFROMZTEidt:
        {
            
            for (UIViewController *vc in self.navigationController.childViewControllers) {
                if ([vc isKindOfClass:[MyAllZCViewController class]]) {
                    [self.navigationController popToViewController:vc animated:YES];
                    return;
                }
            }
            
            NSMutableArray *vcarray=[[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];
            
            [vcarray removeObjectAtIndex:self.navigationController.viewControllers.count-3];
            self.navigationController.viewControllers = vcarray;
            MyAllZCViewController *vc=[MyAllZCViewController Viewcontroller];
            vc.isFromSUS=YES;
            [self.navigationController pushViewController:vc animated:YES];
            
            
        }
            break;
        case POSTADDZTCARFROMCARDETAIL:
        {
            
            
            
            MyAllZCViewController *cavc=[MyAllZCViewController Viewcontroller];
            cavc.hidesBottomBarWhenPushed=YES;
            cavc.isFromSUS=YES;
            [self.navigationController pushViewController:cavc animated:YES];
            
            
            
        }
            break;
            
        default:
            break;
    }
    
}
- (IBAction)indexclick:(id)sender {
    
    if (self.type ==POSTADDZTCARFROMCARDETAIL) {
        MyZTTableViewController *vc=[MyZTTableViewController viewcontroller];
        vc.isFromSUS=YES;
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if(self.type==POSTADDZTCARFROMZT||self.type==POSTADDZTCARFROMZTEidt){
        for (UIViewController *vc in self.navigationController.viewControllers) {
            if ([vc isKindOfClass:[MyZTTableViewController class]]) {
                [self.navigationController popToViewController:vc animated:YES];
            }
        }
    }else{
        
        
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
}
- (IBAction)xiangqingclick:(id)sender {
    
    if (self.ID) {
        
        switch (self.type) {
            case POSTCARTYPE:
            {
                
                CarDetailViewController *vc=[CarDetailViewController viewcontroller];
                vc.ID=self.ID;
                vc.isFromSuS=YES;
                [self.navigationController pushViewController:vc animated:YES];
                
                
            }
                break;
            case POSTFINDCARTYPE:
            case POSTFINDCARTYPEFROMEIDT:
            {
                LookForDetailController *VC=[LookForDetailController viewcontroller];
                VC.Fid=self.ID;
                VC.isFromSuS=YES;
                [self.navigationController pushViewController:VC animated:YES];
            }
                break;
            case POSTADDZTCARFROMZT:
            {
                MyZTCarDetailTableViewController *VC=[MyZTCarDetailTableViewController Viewcontroller];
                VC.ID=self.ID;
                VC.isFromSUS=YES;
                [self.navigationController pushViewController:VC animated:YES];
            }
                break;
            case POSTADDZTCARFROMCARDETAIL:
            {
                MyZTCarDetailTableViewController *VC=[MyZTCarDetailTableViewController Viewcontroller];
                VC.ID=self.ID;
                VC.isFromSUS=YES;
                [self.navigationController pushViewController:VC animated:YES];
            }
                break;
            case POSTADDZTCARFROMZTEidt:
            {
                for (UIViewController *vc in self.navigationController.viewControllers) {
                    if ([vc isKindOfClass:[MyZTCarDetailTableViewController class]]) {
                        MyZTCarDetailTableViewController *zvc=vc;
                        zvc.ID=self.ID;
                        [self.navigationController popToViewController:zvc animated:YES];
                    }
                }
                
            }
                break;
            default:
                break;
        }
        
    }
    
}
- (IBAction)contiueclick:(id)sender {
    if (self.type==POSTADDZTCARFROMCARDETAIL) {
        addTableViewController *vc=[addTableViewController Viewcontroller];
        vc.isFromSUS=YES;
        [self.navigationController pushViewController:vc animated:YES];
        return;
    }
    if ([_delegate respondsToSelector:@selector(continueClick)]) {
        [_delegate continueClick];
    }
    [self.navigationController popViewControllerAnimated:YES];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
